﻿using System;
using System.Reflection;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MugenInjection;
using MugenInjection.Core;
using MugenInjection.Interface;

namespace MugenInjectionTest
{
    public delegate MugenInjector GetInjectorDelegate(IInjectorSettings settings = null);

    [TestClass]
    public abstract class TestBase
    {
        #region Properties

        protected GetInjectorDelegate GetInjector { get; set; }

#if NETFX_CORE
        protected Type ServiceType = typeof(Attribute);
        protected TypeInfo TypeInto = typeof(string).GetTypeInfo();
        protected static readonly ParameterInfo ParameterInfo = typeof(TestBase)
            .GetMethod("Method")
            .GetParameters()[0];
#else
        protected readonly static Type ServiceType = typeof(Attribute);
        protected readonly static Type TypeInto = typeof(string);
        protected static readonly ParameterInfo ParameterInfo = typeof (TestBase)
            .GetMethod("Method", BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.NonPublic)
            .GetParameters()[0];
#endif

        #endregion

        #region Methods

        [TestInitialize]
        public void TestInitialize()
        {
            GetInjector = (s) => new MugenInjector(s ?? new DefaultInjectorSetting());
            OnInit();
        }

        protected virtual void OnInit()
        {
        }

        private static void Method(string parameter)
        {
            
        }

        #endregion
    }
}